@(commitId: String,
  commit: gitbucket.core.util.JGitUtil.CommitInfo,
  branches: List[String],
  tags: List[String],
  status: Option[(gitbucket.core.model.CommitState, List[gitbucket.core.model.CommitStatus])],
  comments: List[gitbucket.core.model.Comment],
  repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
  diffs: Seq[gitbucket.core.util.JGitUtil.DiffInfo],
  oldCommitId: Option[String],
  hasWritePermission: Boolean,
  info: Option[Any] = None,
  error: Option[Any] = None)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@import gitbucket.core.view.helpers.RichHtmlSeq
@import gitbucket.core.model._
@gitbucket.core.html.main(commit.shortMessage, Some(repository)){
  @gitbucket.core.html.menu("files", repository, None, info, error){
    <table class="table table-bordered">
      <tr>
        <th class="box-header">
          <div class="pull-right align-right btn-group">
            <a href="@helpers.url(repository)/tree/@commit.id" class="btn btn-default">Browse code</a>
            @if(hasWritePermission) {
              <a href="@helpers.url(repository)/tag/@commit.id" class="btn btn-default" rel="facebox">Add tag</a>
            }
          </div>
          <div class="commit-log">@helpers.link(commit.summary, repository)</div>
          @if(commit.description.isDefined){
            <pre class="commit-description">@helpers.link(commit.description.get, repository)</pre>
          }
          <div class="small" style="font-weight: normal;">
            @if(branches.nonEmpty){
              <span class="muted">
                <i class="octicon octicon-git-branch"></i>
                @branches.zipWithIndex.map { case (branch, i) =>
                  <a href="@helpers.url(repository)/tree/@helpers.encodeRefName(branch)" class="branch" id="branch-@i">@branch</a>
                }
              </span>
            }
            @if(tags.nonEmpty){
              <span class="muted">
                <i class="octicon octicon-tag"></i>
                @tags.zipWithIndex.map { case (tag, i) =>
                  <a href="@helpers.url(repository)/tree/@tag" class="tag" id="tag-@i">@tag</a>
                }
              </span>
            }
          </div>
        </th>
      </tr>
      <tr>
        <td>
          <div class="pull-right">
            <div>
              @if(commit.parents.size == 0){
                <span class="muted">0 parent</span>
              }
              @if(commit.parents.size == 1){
                <span class="muted">1 parent</span>
                <a href="@helpers.url(repository)/commit/@commit.parents(0)" class="commit-id monospace strong">@commit.parents(0).substring(0, 7)</a>
              }
              <span class="muted ">commit</span> <span class="commit-id monospace strong">@commit.id</span>
            </div>
            @if(commit.parents.size > 1){
              <div>
                <span class="muted">@commit.parents.size parents
                @commit.parents.map { parent =>
                  <a href="@helpers.url(repository)/commit/@parent" class="commit-id monospace strong">@parent.substring(0, 7)</a>
                }.mkHtml(" + ")
                </span>
              </div>
            }
          </div>

          <div class="author-info">
            <div class="author">
              @helpers.avatarLink(commit, 20)
              <span>@helpers.user(commit.authorName, commit.authorEmailAddress, "username strong")</span>
              <span class="muted">authored @gitbucket.core.helper.html.datetimeago(commit.authorTime)</span>
              @status.map { case (summary, statuses) =>
                @gitbucket.core.helper.html.commitstatus(commit.id, summary, statuses)
              }
            </div>
            @if(commit.isDifferentFromAuthor) {
              <div class="committer">
                <span class="octicon octicon-arrow-right"></span>
                <span>@helpers.user(commit.committerName, commit.committerEmailAddress, "username strong")</span>
                <span class="muted"> committed @gitbucket.core.helper.html.datetimeago(commit.commitTime)</span>
              </div>
            }
          </div>
        </td>
      </tr>
    </table>
    @gitbucket.core.helper.html.diff(diffs, repository, Some(commit.id), oldCommitId, true, None, hasWritePermission, true)
    <label class="checkbox">
      <input type="checkbox" id="show-notes"> Show line notes below
    </label>
    <div id="comment-list">
      @gitbucket.core.issues.html.commentlist(
        issue        = None,
        comments     = comments.filter(_.asInstanceOf[CommitComment].fileName.isEmpty),
        isManageable = hasWritePermission,
        repository   = repository,
        pullreq      = None,
        renderScript = false)
      <div style="display: none;">
        @gitbucket.core.issues.html.commentlist(
          issue        = None,
          comments     = comments.map(_.asInstanceOf[CommitComment]).filter(_.fileName.isDefined).groupBy(_.fileName).map { case (fileName, comments) =>
            CommitComments(
              fileName          = fileName.get,
              commentedUserName = comments.head.commentedUserName,
              registeredDate    = comments.head.registeredDate,
              comments          = comments,
              diff              = None
            )
          }.toList,
          isManageable = hasWritePermission,
          repository   = repository,
          pullreq      = None,
          commitId     = Some(commitId))
      </div>
    </div>
    @gitbucket.core.repo.html.commentform(commitId = commitId, hasWritePermission = hasWritePermission, repository = repository)
  }
}
<script>
$(function(){
  $('a.branch:first, a.tag:first').css({
    'font-weight': 'bold',
    'color': '#555555'
  });

  @if(branches.size > 5){
    // hide branches
    @for(i <- 1 to branches.size - 2){
      $('#branch-@i').hide();
    }
    // add omit link
    $('#branch-@(branches.size - 1)').before(
      $('<a href="javascript:void(0);" class="omit">...</a>').click(function(){
        @for(i <- 1 to branches.size - 2){
          $('#branch-@i').show();
          this.remove();
        }
      })
    );
  }

  @if(tags.size > 5){
    // hide tags
    @for(i <- 1 to tags.size - 2){
      $('#tag-@i').hide();
    }
    // add omit link
    $('#tag-@(tags.size - 1)').before(
      $('<a href="javascript:void(0);" class="omit">...</a>').click(function(){
        @for(i <- 1 to tags.size - 2){
          $('#tag-@i').show();
          this.remove();
        }
      })
    );
  }

  $('#show-notes').change(function() {
    if (this.checked) {
      $('.inline-comment').show();
    } else {
      $('.inline-comment').hide();
      $('.diff .inline-comment').show();
    }
  });
});
</script>
<style type="text/css">
a.branch, a.tag {
  color: #888888;
  margin-right: 4px;
}

a.omit {
  margin-right: 4px;
}
</style>
